home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / gcc_260.zip / gcc_260 / vmsconfig.com < prev    next >
Text File  |  1994-07-11  |  11KB  |  348 lines

  1. $ !
  2. $ !    Set up to compile GCC on VAX/VMS
  3. $ !
  4. $! Set the def dir to proper place for use in batch. Works for interactive too.
  5. $flnm = f$enviroment("PROCEDURE")     ! get current procedure name
  6. $set default 'f$parse(flnm,,,"DEVICE")''f$parse(flnm,,,"DIRECTORY")'
  7. $ !
  8. $set symbol/scope=(nolocal,noglobal)
  9. $ !
  10. $ echo = "write sys$output"
  11. $ !
  12. $ if f$search("config.h") .nes. "" then delete config.h.*
  13. $ copy [.config.vax]xm-vms.h []config.h
  14. $ echo "Linked `config.h' to `[.config.vax]xm-vms.h'.
  15. $ !
  16. $ if f$search("tconfig.h") .nes. "" then delete tconfig.h.*
  17. $ create []tconfig.h
  18. $DECK
  19. /* tconfig.h == config.h :: target and host configurations are the same */
  20. #include "config.h"
  21. $EOD
  22. $ echo "Created `tconfig.h'.
  23. $ !
  24. $ if f$search("hconfig.h") .nes. "" then delete hconfig.h.*
  25. $ create []hconfig.h
  26. $DECK
  27. /* hconfig.h == config.h :: host and target configurations are the same */
  28. #include "config.h"
  29. $EOD
  30. $ echo "Created `hconfig.h'.
  31. $ !
  32. $ if f$search("tm.h") .nes. "" then delete tm.h.*
  33. $!! copy [.config.vax]vms.h []tm.h
  34. $ edit/tpu/nojournal/nosection/nodisplay/command=sys$input -
  35.         [.config.vax]vms.h /output=[]tm.h
  36. $DECK
  37. !
  38. !  Copy file, changing lines of the form
  39. !    #include "vax/*"
  40. !  into
  41. !    #include "config-*"
  42. !
  43.    file := CREATE_BUFFER("file", GET_INFO(COMMAND_LINE, "file_name"));
  44.    targ := LINE_BEGIN & '#include' & SPAN(ASCII(32)+ASCII(9)) & '"vax/';
  45.    rang := CREATE_RANGE(BEGINNING_OF(file), END_OF(file));
  46.    LOOP
  47.       incl := SEARCH_QUIETLY(targ, FORWARD, EXACT, rang);
  48.       EXITIF incl = 0;
  49.       POSITION(BEGINNING_OF(incl));
  50.       ERASE(incl);
  51.       COPY_TEXT('#include "config-');
  52.       rang := CREATE_RANGE(END_OF(incl), END_OF(file));
  53.    ENDLOOP;
  54.    WRITE_FILE(file, GET_INFO(COMMAND_LINE, "output_file"));
  55.    QUIT
  56. $EOD
  57. $ echo "Generated `tm.h' from `[.config.vax]vms.h'.
  58. $ !
  59. $    !crude hack to allow compiling from [.cp] subdirectory
  60. $ if f$search("config-vax.h") .nes. "" then delete config-vax.h;*
  61. $ copy [.config.vax]vax.h []config-vax.h
  62. $ echo "Linked `config-vax.h' to `[.config.vax]vax.h' for `tm.h'."
  63. $ !
  64. $ if f$search("md.") .nes. "" then delete md..*
  65. $ copy [.config.vax]vax.md []md.
  66. $ echo "Linked `md' to `[.config.vax]vax.md'.
  67. $ !
  68. $ if f$search("aux-output.c") .nes. "" then delete aux-output.c.*
  69. $ copy [.config.vax]vax.c []aux-output.c
  70. $ echo "Linked `aux-output.c' to `[.config.vax]vax.c'.
  71. $ !
  72. $!
  73. $!
  74. $! Create the file version.opt, which helps identify the executable.
  75. $!
  76. $search version.c version_string,"="/match=and/output=t.tmp
  77. $open ifile$ t.tmp
  78. $read ifile$ line
  79. $close ifile$
  80. $delete t.tmp;
  81. $ijk=f$locate("""",line)+1
  82. $line=f$extract(ijk,f$length(line)-ijk,line)
  83. $ijk=f$locate("""",line)
  84. $line=f$extract(0,ijk,line)
  85. $ijk=f$locate("\n",line)
  86. $line=f$extract(0,ijk,line)
  87. $!
  88. $i=0
  89. $loop:
  90. $elm=f$element(i," ",line)
  91. $if elm.eqs."" then goto no_ident
  92. $if (elm.les."9").and.(elm.ges."0") then goto write_ident
  93. $i=i+1
  94. $goto loop
  95. $!
  96. $no_ident:
  97. $elm="?.??"
  98. $!
  99. $!
  100. $write_ident:
  101. $open ifile$ version.opt/write
  102. $write ifile$ "ident="+""""+elm+""""
  103. $close ifile$
  104. $purge version.opt
  105. $!
  106. $!
  107. $! create linker options files that lists all of the components for all
  108. $! possible compilers.  We do this by editing the file Makefile.in, and 
  109. $! generating the relevant files from it.
  110. $!
  111. $!
  112. $! Make a copy of the makefile if the sources are on a disk that is NFS 
  113. $!    mounted on a unix machine.
  114. $if f$search("Makefile.in").eqs."" .and. f$search("$M$akefile.in").nes."" -
  115.     then copy $M$akefile.in Makefile.in
  116. $! This should be automated across all front-end subdirectories.
  117. $!    For now, it's hardcoded.
  118. $if f$search("[.cp]Makefile.in").eqs."" .and. f$search("[.cp]$M$akefile.in").nes."" -
  119.     then copy [.cp]$M$akefile.in [.cp]Makefile.in
  120. $!
  121. $!
  122. $echo "Now processing Makefile.in to generate linker option files."
  123. $edit/tpu/nojournal/nosection/nodisplay/command=sys$input
  124.    PROCEDURE generate_option_file (TAG_NAME, outfile)
  125.         position (beginning_of (newbuffer));
  126.         recursive_fetch_tag (TAG_NAME);
  127. !
  128. ! Now fix up a few things in the output buffer
  129. !
  130.     pat_replace ("bytecode "," ");
  131.     pat_replace (".o ",",");
  132.     pat_replace (".o","");  !appear at end of lines.
  133. !
  134. ! Remove trailing commas, if present.
  135. !
  136.     position (beginning_of (newbuffer));
  137.     LOOP
  138.       range1 := search_quietly("," & ((SPAN(" ") & LINE_END) | LINE_END),
  139.                    FORWARD, EXACT);
  140.       exitif range1 = 0;
  141.       position (beginning_of (range1));
  142.       erase(range1);
  143.       split_line;        
  144.       ENDLOOP;
  145. ! get rid of leading spaces on lines.
  146.         position (beginning_of (current_buffer)) ;
  147.     LOOP
  148.           range1 := search_quietly ( LINE_BEGIN & " ", FORWARD, EXACT) ;
  149.       EXITIF range1 = 0;
  150.       position (end_of (range1));
  151.       erase_character(1);
  152.     ENDLOOP;       
  153. !
  154. ! Now write the output file.
  155. !
  156.     SET(OUTPUT_FILE, newbuffer, outfile);
  157.       write_file (newbuffer);
  158.       erase (newbuffer);
  159.    ENDPROCEDURE;
  160.  
  161. !
  162. ! Looks up a tag, copies it to newbuffer, and then translates any $(...)
  163. ! definitions that appear.  The translation is put at the current point.
  164. !
  165.    PROCEDURE recursive_fetch_tag (TAG_N);
  166.    fetch_tag (TAG_N);
  167. !
  168. ! substitute any  makefile symbols $(...)
  169. !
  170.         position (beginning_of (current_buffer)) ;
  171.     LOOP
  172.       range1 := search_quietly ("$(" &  
  173.       SPAN("abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ#~0123456789")
  174.                     & ")", FORWARD, EXACT) ;
  175.       EXITIF range1 = 0;
  176.       position (beginning_of (range1));
  177.       move_horizontal(2);
  178.       mark_1 := MARK (NONE);
  179.       position (end_of (range1));
  180.       move_horizontal(-1);
  181.       mark_2 := MARK (NONE);
  182.       tag_range := CREATE_RANGE(MARK_1, MARK_2, NONE);
  183.       position (end_of (range1));
  184.       tag_string := STR (tag_range);
  185.       erase (range1);
  186.       fetch_tag (LINE_BEGIN & tag_string & ((SPAN(" ") & "=") | "="));
  187.           position (beginning_of (current_buffer)) ;
  188.     ENDLOOP;       
  189.    ENDPROCEDURE;
  190.  
  191. !
  192. ! Looks up the translation of a tag, and inserts it at the current location
  193. ! in the buffer
  194. !
  195.    PROCEDURE fetch_tag (TAG_N);
  196.       LOCAL mark1, mark2, mark3, range2;
  197.       mark3 := MARK(NONE) ;
  198.       position (beginning_of (mainbuffer)) ;
  199.       range2 := search_quietly (TAG_N, FORWARD, EXACT) ;
  200.       IF (range2 = 0) then 
  201.     position (mark3);
  202.     return;
  203.     endif;
  204.       position (end_of (range2)) ;
  205.       MOVE_HORIZONTAL(1);
  206.       mark1 := MARK(NONE) ;
  207.       position (beginning_of (range2)) ;
  208.       MOVE_VERTICAL(1);
  209.       MOVE_HORIZONTAL(-2);
  210.       LOOP
  211.     EXITIF CURRENT_CHARACTER <> "\" ;
  212.     ERASE_CHARACTER(1);
  213.     MOVE_HORIZONTAL(1);
  214.     MOVE_VERTICAL(1);
  215.     MOVE_HORIZONTAL(-2);
  216.     ENDLOOP;
  217.       MOVE_HORIZONTAL(1);
  218.       mark2 := MARK(NONE) ;
  219.       range2 := CREATE_RANGE(mark1, mark2, NONE) ;
  220.       position (mark3);
  221.       if (length(range2) = 0) then return; endif;
  222.       copy_text(range2);
  223.    ENDPROCEDURE;
  224.  
  225.    PROCEDURE pat_replace (
  226.       oldstring, !
  227.       newstring)  !
  228.       LOCAL range2;
  229.       position (beginning_of (current_buffer)) ;
  230.       LOOP
  231.          range2 := search_quietly (oldstring, FORWARD, EXACT) ;
  232.          EXITIF range2 = 0 ;
  233.          position (beginning_of (range2)) ;
  234.          erase (range2) ;
  235.          copy_text (newstring) ;
  236.          ENDLOOP ;
  237.    ENDPROCEDURE ;
  238.  
  239. !                !
  240. ! ...fix this... !
  241. !                !
  242.  procedure temporary_cplusplus_hack()
  243.   position(end_of(compiler_list));
  244.   copy_text("cc1plus");
  245.   position(end_of(mainbuffer));
  246.   copy_text("cc1plus: [.cp]call,[.cp]decl,[.cp]errfn,[.cp]expr,[.cp]pt,[.cp]sig\");  split_line;
  247.   copy_text(" [.cp]typeck2,[.cp]class,[.cp]decl2,[.cp]error,[.cp]gc,[.cp]lex\");  split_line;
  248.   copy_text(" [.cp]parse,[.cp]ptree,[.cp]spew,[.cp]typeck,[.cp]cvt,[.cp]edsel\");  split_line;
  249.   copy_text(" [.cp]except,[.cp]init,[.cp]method,[.cp]search,[.cp]tree,[.cp]xref\");  split_line;
  250.   copy_text(" []c-common\");  split_line;
  251.   copy_text(" bc-emit,bc-optab\");  split_line;
  252.   copy_text(" obstack");  split_line;
  253.  endprocedure;
  254.  
  255.  
  256. !
  257. ! this is the start of the main procedure
  258.    filename := GET_INFO (COMMAND_LINE, 'file_name') ;
  259.    mainbuffer := CREATE_BUFFER ("Makefile.in", "Makefile.in") ;
  260.    newbuffer := CREATE_BUFFER("outfile");
  261.    compiler_list := CREATE_BUFFER("compilers");
  262. !
  263. ! Add to this list, as required.  The file "Makefile.in" is searched for a
  264. ! tag that looks like "LINE_BEGIN + 'tag + (optional space) + "="".  The
  265. ! contents are assumed to be a list of object files, and from this list a
  266. ! VMS linker options file is generated.
  267. !
  268.    position (beginning_of (compiler_list));
  269.    recursive_fetch_tag(LINE_BEGIN & "COMPILERS" & ((SPAN(" ") & "=") | "="));
  270.    position (beginning_of (compiler_list));
  271.    LOOP ! kill leading spaces.
  272.     exitif current_character <> " ";
  273.     erase_character(1);
  274.     ENDLOOP;
  275.    position (beginning_of (compiler_list));
  276.       LOOP ! remove any double spaces.
  277.          range1 := search_quietly ("  ", FORWARD, EXACT) ; EXITIF range1 = 0 ;
  278.          position (beginning_of (range1)) ;
  279.          erase_character(1);
  280.          ENDLOOP ;
  281.    position (end_of (compiler_list));
  282.    move_horizontal(-1);
  283.    LOOP ! kill trailing spaces.
  284.     exitif current_character <> " ";
  285.     erase_character(1);
  286.     move_horizontal(-1);
  287.     ENDLOOP;
  288.    position (beginning_of (compiler_list));
  289.       LOOP
  290.          range1 := search_quietly (" ", FORWARD, EXACT) ;
  291.          EXITIF range1 = 0 ;
  292.          position (beginning_of (range1)) ;
  293.          erase (range1) ;
  294.      split_line;
  295.          ENDLOOP ;
  296. !                         !
  297. ! This needs to be fixed. !
  298. !                         !
  299.     temporary_cplusplus_hack();
  300. !
  301. ! We now have a list of supported compilers.  Now write it, and use it.
  302. !
  303.     SET(OUTPUT_FILE, compiler_list, "compilers.list");
  304.       write_file (compiler_list);
  305.    generate_option_file(LINE_BEGIN & "OBJS" & ((SPAN(" ") & "=") | "="),
  306.             "independent.opt");
  307.    generate_option_file(LINE_BEGIN & "LIB2FUNCS" & ((SPAN(" ") & "=") | "="),
  308.             "libgcc2.list");
  309.    generate_option_file(LINE_BEGIN & "BC_ALL" & ((SPAN(" ") & "=") | "="),
  310.             "bc_all.opt");
  311.    generate_option_file(LINE_BEGIN & "BI_OBJ" & ((SPAN(" ") & "=") | "="),
  312.             "bi_all.opt");
  313. !
  314. ! Now change OBJS in the Makefile, so each language specific options file 
  315. ! does not pick up all of the language independent files.
  316. !
  317.    position (beginning_of (mainbuffer));
  318.    range1 := search_quietly (LINE_BEGIN & "OBJS" & ((SPAN(" ") & "=") | "="),
  319.                  FORWARD, EXACT) ;
  320.    position (end_of (range1));
  321.    split_line;
  322.    position (beginning_of (compiler_list));
  323.    LOOP
  324.      cmark := mark(NONE);
  325.      exitif cmark = end_of(compiler_list);
  326.      message(current_line);
  327.      generate_option_file(LINE_BEGIN & current_line & ((SPAN(" ") & ":") | ":"),
  328.               current_line+"-objs.opt");
  329.      position (cmark);
  330.      move_vertical(1);
  331.    ENDLOOP ;
  332.    quit ;
  333. $ echo ""
  334. $!
  335. $! Remove excessive versions of the option files...
  336. $!
  337. $ purge *.opt
  338. $ purge compilers.list,libgcc2.list
  339. $!
  340. $!
  341. $!
  342. $ if f$search("config.status") .nes. "" then delete config.status.*
  343. $ open/write file config.status
  344. $ write file "Links are now set up for use with a vax running VMS."
  345. $ close file
  346. $ type config.status
  347. $ echo ""
  348.